package cn.iot.sys.service.impl;

import cn.iot.common.dto.ResultMsg;
import cn.iot.sys.dao.SysDocumentDao;
import cn.iot.sys.entity.SysDocument;
import cn.iot.sys.service.SysDocumentService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SysDocumentServiceImpl implements SysDocumentService {
    @Resource
    private SysDocumentDao sysDocumentDao;
    private Logger logger = LoggerFactory.getLogger(getClass());

    @Override
    public ResultMsg getSysDocumentList() {
        logger.info("SysDocumentServiceImpl getSysDocumentList start...");
        List<SysDocument> sysDocumentList = sysDocumentDao.getSysDocumentList();
        ResultMsg msg = new ResultMsg(200,"成功",sysDocumentList);
        return msg;
    }

    @Override
    public ResultMsg getSysDocumentByName(String documentName) {
        logger.info("SysDocumentServiceImpl getSysDocumentByName documentName{}",documentName);
        SysDocument sysDocumentByName = sysDocumentDao.getSysDocumentByName(documentName);
        ResultMsg msg;
        if (sysDocumentByName != null){
            msg = new ResultMsg(200,"成功",sysDocumentByName);
            return msg;
        }
        msg = new ResultMsg(500,"失败",null);
        return msg;
    }
}
